layui.cache.page = 'user';
layui.cache.user = {
    username: '游客'
    , uid: -1
    , avatar: '../../res/images/avatar/00.jpg'
    , experience: 83
    , sex: '男'
};
layui.config({
    version: "3.0.0"
    , base: '../../res/mods/'
}).extend({
    fly: 'index'
}).use('fly');

//登录
$(".login_form_con").submit(function (e) {
    e.preventDefault()
    var email = $(".layui-form-item #L_email").val();
    var password = $(".layui-form-item #L_pass").val();

    // if (!email) {
    //     $("#login-mobile-err").show();
    //     return;
    // }
    //
    // if (!password) {
    //     $("#login-password-err").show();
    //     return;
    // }

    var params = {
        "email": email,
        "password": password,
    }

    $.ajax({
        url: "/passport/login",
        method: "post",
        data: JSON.stringify(params),
        contentType: "application/json",
        success: function (resp) {
            if (resp.errno == "0") {
                // 刷新当前界面
                location.href = '/'
            } else {
                $("#register-err").html(resp.errmsg)
                $("#register-err").show()
            }
        }
    })
})
